from tortoise import BaseDBAsyncClient


async def upgrade(db: BaseDBAsyncClient) -> str:
    return """
        ALTER TABLE `jobs` ADD `detail` LONGTEXT NOT NULL COMMENT '工作详情';
        CREATE TABLE IF NOT EXISTS `user_expectations` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `job_name` VARCHAR(255) NOT NULL COMMENT '期望职位名称',
    `money` DECIMAL(10,2) NOT NULL COMMENT '期望薪资',
    `place` VARCHAR(255) NOT NULL COMMENT '期望工作地点',
    `industry` VARCHAR(255) NOT NULL COMMENT '期望行业',
    `created_at` DATETIME(6) NOT NULL COMMENT '创建时间' DEFAULT CURRENT_TIMESTAMP(6),
    `updated_at` DATETIME(6) NOT NULL COMMENT '更新时间' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
    `user_id` INT NOT NULL COMMENT '关联用户',
    CONSTRAINT `fk_user_exp_user_2cc1602b` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) CHARACTER SET utf8mb4 COMMENT='用户求职期望表';"""


async def downgrade(db: BaseDBAsyncClient) -> str:
    return """
        ALTER TABLE `jobs` DROP COLUMN `detail`;
        DROP TABLE IF EXISTS `user_expectations`;"""
